package com.review.reviewsb.service.impl;

import com.review.reviewsb.domain.User;
import com.review.reviewsb.mapper.UserMapper;
import com.review.reviewsb.mapper.VideoMapper;
import com.review.reviewsb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * @program: reviewSb
 * @description:
 * @author: YaoZhiLi
 * @create: 2021-07-03 08:50
 */

@Service
public class UserServiceImpl implements UserService {
    public static Map<String, User> sessionMap=new HashMap<>();

    @Autowired
    private UserMapper userMapper;

    @Override
    public String login(String username, String password) {
        User login = userMapper.login(username, password);
        if (login == null) {
            return null;
        } else {
            String token = UUID.randomUUID().toString();
            System.out.println(token);
            sessionMap.put(token,login);
            return token;
        }
    }

    @Override
    public List listUser() {
        return userMapper.userList();
    }
}